import { ctx } from "../../entrance/inter";
import cookie from "../../cookie/cookie";
import sugar from "../../core/sugar";
import Request from "../../interface/Request";
/**
 * 封装的请求头
 */
 
export = class RequestModel implements Request{
    public url:string=null;
    public method:string=null;
    public $file:any[] = [];

    constructor(ctx:ctx){
        this.cookie.ctx = ctx;
        this.url = sugar.url(ctx.req.url).replace(/\?.*/,"");
        this.method = ctx.req.method.toLowerCase();
    }
    
    public cookie:any = {
        ctx:null,
        get(key?:string){return cookie.get(this.ctx,key)},
        set(name:any,value:any,obj?:any,data:any=[]){return cookie.set(this.ctx,name,value,obj,data)},
    }
}